<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const  person = {
        name:"jack",
        age:21,
        language:['jack','js','css']
    }
    console.log(Object.keys(person))
    console.log(Object.values(person))
    console.log(Object.entries(person))

    // 合并对象
    const target = {a:1}
    const source1 = {b:2}
    const source2 = {c:3}
    let assign = Object.assign(target,source1,source2);
    console.log(assign)

    // 声明对象简写
    const age =23
    const name = "张三"
    const person1 = {age:age,name:name}
    const person2 ={age,name}
    console.log(person1)
    console.log(person2)

    // 对象的函数属性简写
    let person3={
        name:"jack",
        eat:function (food) {
            console.log(this.name+"再吃"+food)
        },
        // 箭头函数this不能使用
        eat2:food=>console.log(name+"再吃"+food),
        eat3(food){
            console.log(this.name+"再吃"+food)
        }
    }
    person3.eat("香蕉")
    person3.eat2("苹果")
    person3.eat3("橘子")

    // 拷贝对象 深拷贝
    let p1={name:"Amy",age:15}
    let someone={...p1}
    console.log(someone)

    // 合并对象
    let age1={
        age:15,
    }
    let name1={
        name:"Amy"
    }
    let p = {
        ...age1,
        ...name1
    }
    console.log(p)
</script>
</body>
</html>